﻿//-----------------------------------------------------------------------------------------------------------
// WBFSSync Project by Omega Frost 
// http://wbfssync.codeplex.com/
//
// WBFSSync is Licensed under the terms of the 
// Microsoft Reciprocal License (Ms-RL)
//-----------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WBFSe3.Wbfs
{
    public static class WbfsConstants
    {
        //------------------------------------------------------------------------------------------
        // Wbfs partition
        //------------------------------------------------------------------------------------------
        public const uint WbfsMagic = (('W' << 24) | ('B' << 16) | ('F' << 8) | ('S'));
        
        public const int WbfsHeadMagicPos = 0;
        public const int WbfsHeadNSecsPos = 4;
        public const int WbfsHeadHdSecSzPos = 8;
        public const int WbfsHeadWbfsSecSzPos = 9;
        public const int WbfsHeadDiscTablePos = 12;
        
        public const int WbfsDiscHCopySz = 256;

        public const long WbfsPartitionMaxSize = 1L << 40; // 1TB

        public const int WbfsDefaultSectorSizeLsh = 21;
        public const int WbfsDefaultSectorSize = 1 << 21;
        

        //------------------------------------------------------------------------------------------
        // Wii disc
        //------------------------------------------------------------------------------------------
        public const int WiiSectorSize = 32768;
        public const int WiiSectorSizeLSh = 15;
        public const int WiiSectorsPerDisc = 286864;

        public const int WiiCodePos = 0;
        public const int WiiCodeLen = 6;
        public const int WiiNamePos = 32;
        public const int WiiNameLen = 64;

        public const int WiiMagic1Pos = 24;
        public const int WiiMagic2Pos = 327676;
        public const uint WiiMagic1 = 0x5D1C9EA3;
        public const uint WiiMagic2 = 0xC3F81A8E;

        public static readonly byte[] DiscCommonKey =
            new byte[] { 0xeb, 0xe4, 0x2a, 0x22, 0x5e, 0x85, 0x93, 0xe4, 
                         0x48, 0xd9, 0xc5, 0x45, 0x73, 0x81, 0xaa, 0xf7 };

        public static readonly byte[] DefaultJapRegionCode =
            new byte[] { 0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
                         0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };

        public static readonly byte[] DefaultUsaRegionCode =
            new byte[] { 0x80, 0x06, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
                         0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };

        public static readonly byte[] DefaultPalRegionCode =
            new byte[] { 0x80, 0x80, 0x80, 0x00, 0x03, 0x03, 0x04, 0x03, 
                         0x00, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 };
    }
}
